import riskClient from "./riskClient";

export const findCfgNotices = async (params) => {
  return await riskClient.postAsync({
    url: 'api/unitConfig/findCfgNotices',
    params,
  })
}

export const addOrEditCfgNotice = async (params) => {
  return await riskClient.postAsync({
    url: 'api/unitConfig/addOrEditCfgNotice',
    params,
  })
}

export const findTemplateByUnitCode = async (params) => {
  const {data, error} = await riskClient.getAsync({
    url: 'api/unitConfig/findTemplateByUnitCode',
    params,
  })
  if (error) return []

  const Templates = data?.map((item) => ({
      value: item.msgTempId,
      label: item.title,
      content: item.content,
    }))

  return Templates
}

export const deleteCfgNoticeById = async (params) => {
  return await riskClient.getAsync({
    url: 'api/unitConfig/deleteCfgNoticeById',
    params,
  })
}